package com.wxapp.dispatch.service.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.dispatch.api.pojo.vm.dispatchlogs.PDispatchLogDetailVm;
import com.wxapp.dispatch.api.pojo.vm.dispatchlogs.PDispatchLogPageVm;
import com.wxapp.dispatch.api.pojo.vo.dispatchlogs.QDispatchLogPageVo;
import com.wxapp.dispatch.service.service.DispatchLogsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author lgl
 * @Description 调度管理
 * @Datetime 2023/5/26 17:58
 * @Modified By
 */
@RestController
@Tag(name = "调度日志")
@RequestMapping("dis/logs")
@RequiredArgsConstructor
public class DispatchLogsController extends IBaseController {

    private final DispatchLogsService dispatchLogsService;

    @PostMapping("page")
    @Operation(summary ="调度日志分页")
    public ResultVm<Page<PDispatchLogPageVm>> page(@RequestBody QDispatchLogPageVo vm) {
        return dispatchLogsService.page(vm);
    }

    @GetMapping("detail/{id}")
    @Operation(summary ="调度日志详细日志")
    public ResultVm<PDispatchLogDetailVm> detail(@PathVariable String id) {
        return dispatchLogsService.detail(id);
    }

    @DeleteMapping("delete")
    @Operation(summary ="删除调度日志")
    public ResultVm<PDispatchLogDetailVm> delete(@RequestParam LocalDateTime endTime) {
        return dispatchLogsService.delete(endTime);
    }
}
